package com.example.file.util;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author Jiamingzhen
 * @Date 2021/4/26 10:01
 * @ClassName FileUtil
 * @Introduce
 */
@Component
public class FileUtil {
    // windows 文件路径
    public static  String WINDOWS_PATH = "";
    // linux 文件路径
    public static  String LINUX_PATH = "";

    @Value("${file.localtion.windows}")
    public void setWindowsPath(String windows_path) {
        WINDOWS_PATH = windows_path;
    }
    @Value("${file.localtion.linux}")
    public void setLinuxPath(String linuxPath) {
        LINUX_PATH = linuxPath;
    }

    public static String getFilePath(){
        String sys = System.getProperties().getProperty("os.name");
        if(sys.toLowerCase().startsWith("win")){
            return WINDOWS_PATH;
        }
        return LINUX_PATH;
    }
}
